package com.prs.crm.action.approval;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationHelper;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.approval.RedFile;
import com.prs.crm.domain.approval.ShenQingType;
import com.prs.crm.service.approval.RedFileService;

public class RedFileAction extends BaseAction{
	private RedFileService redFileService;
	private RedFile redFile;
	private PaginationSupport pagination;
	private Integer[] ids;
	public RedFileService getRedFileService() {
		return redFileService;
	}
	public void setRedFileService(RedFileService redFileService) {
		this.redFileService = redFileService;
	}
	public RedFile getRedFile() {
		return redFile;
	}
	public void setRedFile(RedFile redFile) {
		this.redFile = redFile;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	//////////////////////////////////////////////////////////////////////////////
	@Action("listRedFile")
	public String listRedFile(){
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(RedFile.class);
		this.setPagination(this.getRedFileService().listByPage(criteria, 
				this.getPaginationHelper().prepare(pagination)));
		return SUCCESS;
	}
	@Action("insertRedFile")
	public String editRedFile(){
		return SUCCESS;
	}
	@Action(value="saveRedFile",results={
			@Result(name="success",type="redirect",location="listRedFile"),
			@Result(name="error",type="chain",location="insertRedFile")
	})
	public String saveRedFile(){
		this.redFileService.save(redFile);
		return SUCCESS;
	}
	@Action(value = "delRedFile", results = {
			@Result(name = "success", type = "redirect", location = "listRedFile"),
			@Result(name = "error", type = "chain", location = "listRedFile") })
	public String removeRedFile(){
		this.redFileService.batchRemove(ids);
		return SUCCESS;
	}
}
